package com.lcw.lostandfound.controller;

import com.lcw.lostandfound.service.GoodsService;
import com.lcw.lostandfound.service.ImgService;
import com.lcw.lostandfound.service.NoticeService;
import com.lcw.lostandfound.service.ThankService;
import com.lcw.lostandfound.util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.Set;

@Controller
public class IndexController {

    @Autowired
    private GoodsService goodsService;
    @Autowired
    private ImgService imgService;

    @Autowired
    private NoticeService noticeService;

    @Autowired
    private ThankService thankService;


    @Autowired
    private RedisUtils redisUtils;
    @RequestMapping({"/","/index"})
    public String index(Model model){

        model.addAttribute("walls",imgService.listWallFindImg());
        model.addAttribute("notices",noticeService.findAllNotice());
        model.addAttribute("thanks",thankService.findWallsThank());
        model.addAttribute("goods",goodsService.listWallsFindMsg());
        model.addAttribute("lostors",goodsService.listWallsLostMsg());
        model.addAttribute("sortList",redisUtils.getRedis());
        return "index";
    }

    @RequestMapping("/loadConstant")
    public String loadConstant(Model model){
        model.addAttribute("sortList",redisUtils.getRedis());
        return "constant";
    }
    @RequestMapping("/findGoods")
    public String findGoods(){
        return "FindGoods";
    }
    @RequestMapping("/findPet")
    public String findPet(){
        return "FindPet";
    }
    @RequestMapping("/findShe")
    public String findShe(){
        return "FindShe";
    }
    @RequestMapping("/findLostor")
    public String findLostor(){
        return "FindLostor";
    }
    @RequestMapping("/about")
    public String about(Model model){
        model.addAttribute("notices",noticeService.findAllNotice());
        model.addAttribute("thanks",thankService.findWallsThank());
        return "about";
    }
}
